<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 7. 编写函数rev(char) 实现将字符串char倒置
    // 比如rev("spring") 返回"gnirps"

    function rev (char) {
      if (typeof char !== 'string') throw new Error('请传入字符串')
      return char.split('').reverse().join('')
    }
    console.log('输入rev(\'spring\'), 返回\'gnirps\'')
    console.log(rev('spring'))
  </script>
</body>
</html>